package com.cloudptt.wp.ui.address.workspace;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cloudptt.api.product.log.Log;
import com.cloudptt.wp.R;

class FuncAdapter extends BaseAdapter {
    public static int[] item_icon_group = {
            R.drawable.settings_about_us_icon
            ,R.drawable.settings_about_us_icon
            ,R.drawable.settings_about_us_icon
            ,R.drawable.settings_about_us_icon
            ,R.drawable.settings_about_us_icon
			,R.drawable.settings_about_us_icon
            ,R.drawable.settings_about_us_icon
    };

    public static int[] item_title_group = {
            R.string.func_login
            ,R.string.func_query
            ,R.string.func_addressing
            ,R.string.func_local
            ,R.string.func_msg
			,R.string.func_compulsory
            ,R.string.func_query_self
    };
    private Context ctx = null;
    public FuncAdapter(Context ctx)
    {
        this.ctx = ctx;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return item_icon_group.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return item_icon_group[position];
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        ViewHolder viewHolder = new ViewHolder();
        if(ctx != null) {
            if (convertView == null) {
                LayoutInflater inflater = LayoutInflater.from(ctx);
                if (inflater != null) {
                    convertView = inflater.inflate(R.layout.settings_item_layout, parent, false);
//            viewHolder.icon = (ImageView)convertView.findViewById(R.id.settings_item_icon);
                    viewHolder.title = (TextView) convertView.findViewById(R.id.settings_item_title);
                    convertView.setTag(viewHolder);
                }
            } else {
                viewHolder = (ViewHolder) convertView.getTag();
            }

            Log.debug(this.getClass(), "getView position = " + position + " item_icon_group.length = " + item_icon_group.length + " item_title_group.length = " + item_title_group.length);
//        viewHolder.icon.setImageResource(item_icon_group[position]);
            viewHolder.title.setText(item_title_group[position]);
        }
        return convertView;
    }

}

final class ViewHolder{
//    public ImageView icon;
    public TextView title;

}
